<html>
<head>
    <title>Reminder</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <script type="text/javascript" src="<?=base_url()?>resource/js/jquery.js"></script>
    
    <link rel="stylesheet" href='<?=base_url()?>resource/css/style.css' type="text/css"/>
    
    <link rel="stylesheet" type="text/css" href="<?=base_url()?>resource/css/jquery.datetimepicker.css" />
    <script src="<?=base_url()?>resource/js/jquery.datetimepicker.js"></script>
    
    <link rel="stylesheet" type="text/css" href="<?=base_url()?>resource/css/jquery.autocompleter.css" />
    <script src="<?=base_url()?>resource/js/jquery.autocompleter.js"></script>
    <style>
        .input-div table tr{display:block;}
    </style>
    <script>
    function preview(oper){
        if (oper < 100000){
            bdhtml=window.document.body.innerHTML;//获取当前页的html代码
            sprnstr="<!--startprint"+oper+"-->";//设置打印开始区域
            eprnstr="<!--endprint"+oper+"-->";//设置打印结束区域
            prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18); //从开始代码向后取html

            prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
            window.document.body.innerHTML=prnhtml;
            window.print();
            window.document.body.innerHTML=bdhtml;
        } else {
            window.print();
        }
        location.reload();
    }
    </script>
</head>
<body>
<?php 
$weekarr = array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
$week = $weekarr[date("w")];
?>
    <div class="reminder-header">
        <h3><?=$date?></h3>
    </div>
    <div class="positiondiv">
        <table>
            <tr>
                <td class="td-left">
                    <img src="<?=base_url()?>resource/img/home_ico.png" width="21" height="17">
                    Reminder > <?=$date?>
                </td>
                <td class="td-right">
                    <img src="<?=base_url()?>resource/img/menu2.png" width="27" height="24">Today is <?=$week?>,<?=date('M d,Y')?>
                </td>
            </tr>
        </table>
    </div>
    <div class="detail-menu">
        <div class="active1 detail-active" id="menu1">Reminder List</div>
        <div class="active2 single-menu" id="menu2">New</div>
        <div style="width:0px;"></div>
    </div>
    <div class="list-div" style="margin-top:0px;">
        <table class="list-table">
            <tr>
                <th width="100">Title</th>
                <th width="100">Notice Time</th>
                <th width="120">Type</th>
                <th width="120"></th>
            </tr>
            <?php foreach ($reminder as $key => $value) {?>
            <tr>
                <td>
                    <a href="<?=base_url('reminder/reminder_detail/'.$value['id'].'/'.$ispickup) ?>" style="color:blue;"><?=$value['title']?></a>
                    <?php if($value['type']==1){?>
                    <a href="javascript:void(0)" class="buttona showinfo" style="display:inline-block;" noticeid="<?=$value['id']?>">
                        <img src="<?=base_url()?>resource/img/detail.png"/></a>
                    
                    <div class="dialogdiv" id="dialogdiv<?=$value['id']?>">
                        <div class="close"></div>
                        <div class="print" onclick=preview(<?=$value['id']?>)></div>
                        <!--startprint<?=$value['id']?>-->
                        <table style="width:95%;height:auto;max-height:100%;margin:auto;overflow: hidden;">
                            <tr>
                                <?php 
                                        $names = explode(" ",$value['name']);
                                        for($i = 0;$i < count($names);$i++){
                                            $str = $names[$i];
                                            $name = "";
                                            if(preg_match("/^[\x7f-\xff]+$/","$str")){ 
                                                $name = $str; 
                                            }
                                        }
                                        if($name != ""){?>
                                <td style="text-align:center;color:#214AAD;font-size:200px;font-family:'宋体';font-weight: bold;text-shadow: 1px 1px 0 #fff,4px 4px 0 #6A3904;">
                                            <?=$name?>
                                    <?php }else{?>
                                <td style="text-align:center;color:#214AAD;font-size:120px;font-family:'宋体';font-weight: bold;text-shadow: 1px 1px 0 #fff,4px 4px 0 #6A3904;">
                                        <?=$value['name']?>
                                    <?php }?>
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align:left;font-size:18px;">
                                    航班号码:&nbsp; <label style="color:black;font-family: '黑体';font-size: 30px;"><?=$value['fltno']?></label>
                                    &nbsp; &nbsp;TERMINAL:&nbsp; <?=$value['terminal']?>&nbsp; &nbsp; 
                                    <label style="color:red;">
                                            <?=$value['worktype']==1?"WP":($value['worktype']==2?"":($value['worktype']==3?"":""))?> 
                                            &nbsp; <?=$value['position']?>
                                    </label> 
                                    &nbsp; <?=$value['username']?> 
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align:left;font-size:18px;">
                                    到达时间:&nbsp; <?=date('d/m/Y',$value['arrivetime'])?>&nbsp; 
                                    <label style="color:black;font-family: '黑体';font-size: 30px;"><?=date('H:i',$value['arrivetime'])?></label>
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align:left;font-size:18px;">
                                    <span>工作地址:<label><?=$value['workaddress']?></label></span>&nbsp; 
                                    <span style='float:right;margin-right:300px;'>公司邮编:<label><?=$value['postcode']?></label></span>
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align:left;font-size:18px;">
                                    住宿:<?=$value['isneedaccommodation']==0?"不需要找房":$value['address']?>
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align:left;font-size:18px;">
                                    工人电话:<?=$value['number']?>
                                </td>
                            </tr>
                        </table>
                        <!--endprint<?=$value['id']?>-->
                    </div>
                    
                    <div class="dialogbgdiv" id="dialogbgdiv<?=$value['id']?>"></div>
                    <?php }?>
                </td>
                <td><?=date("M d,Y ",$value['noticedate']).$value['noticetime']?></td>
                <td><?=$value['type']==1?"Airport Pick-up":"Normal"?></td>
                <td>
                    <a href="<?=base_url('reminder/deletenotice/'.$value['id'].'/'.$date.'/'.$ispickup) ?>" class="buttona" style="display:inline-block;">
                        <img src="<?=base_url()?>resource/img/delete.png"/>delete</a>
                </td>
            </tr>
            <?php }
            if(count($reminder) == 0){?>
            <tr>
                <td colspan="5">
                    NO DATA
                </td>
            </tr>
            <?php }?>
        </table>
    </div>
    <div class="input-div" style="display:none;border:1px solid #C9C9C9;width:95%;border-radius:5px;margin:0px auto 20px;">
        <form action="<?=base_url('reminder/new_reminder')?>" method="post" onkeydown="if(event.keyCode==13)return false;" onsubmit="return checkform()">
            <input type='hidden' value="<?=$date?>" name="noticedate" />
            <input type='hidden' name="association" id="association" />
            <table>
                <tr><td colspan="2"><h3>.Reminder</h3></td></tr>
                <tr><td class="nametd">Notice Date:</td><td><?=$date?></td></tr>
                <tr><td class="nametd">Notice Time:</td><td><input type="text" name="noticetime" id="noticetime" style="width:80px;" readonly="readonly"/></td></tr>
                <tr><td class="nametd">Notice Title:</td><td><input type="text" name="title" style="width:200px;"/><span class="err" id="titleerr">*</span></td></tr>
                <tr><td class="nametd">Notice Comment:</td><td><textarea name="comment" style="height:60px;width:200px;"></textarea></td></tr>
                <tr><td class="nametd">Notice Type:</td>
                    <td>
                        <select name="type" id="type" style="width:120px;">
                            <option value="0">Normal
                            <option value="1">Airport pick-up
                            <option value="6">permit process
                            <option value="7">delivery
                            <option value="8">course
                        </select>
                    </td>
                </tr>
                <tr class="pickup" style="display:none;"><td class="nametd">Flight Number:</td><td><input type="text" name="fltno" style="width:200px;"/><span class="err" id="fltnoerr">*</span></td></tr>
                <tr class="pickup" style="display:none;"><td class="nametd">The Terminal:</td><td><input type="text" name="terminal" style="width:200px;"/><span class="err" id="terminalerr">*</span></td></tr>
                <tr class="pickup" style="display:none;"><td class="nametd">Arrive Time:</td><td><input type="text" name="arrivetime" id="arrivetime" readonly="readonly" style="width:200px;"/><span class="err" id="arrivetimeerr">*</span></td></tr>
                <tr><td class="nametd">Candidate:</td><td><input type="text" name="candidate" id="candidate" readonly="readonly" style="width:200px;"/></td></tr>
                <tr>
                    <td class="nametd">Publicity:</td>
                    <td>
                        <input type="radio" name="ispublic" value="0" checked="checked" id="no" /><label for="no">No</label>
                        <input type="radio" name="ispublic" value="1" id="yes" /><label for="yes">Yes</label>
                    </td>
                </tr>
                <tr><td class="nametd"></td><td><input type='submit' value='Submit'/></td></tr>
            </table>
        </form>
    </div>
<script>
cutmenu();
function cutmenu(){
    $(".single-menu").click(function(){
        $(".detail-active").removeClass("detail-active").addClass("single-menu");
        $(this).removeClass("single-menu").addClass("detail-active");
        var id = $(this).attr("id");
        if(id == "menu1"){
            $(".input-div").css("display","none");
            $(".list-div").css("display","block");
        }else{
            $(".input-div").css("display","block");
            $(".list-div").css("display","none");
        }
        cutmenu();
    });
}

$('#noticetime').datetimepicker({
    datepicker:false,
    format:'H:i',
    step:5
});

$('#arrivetime').datetimepicker({
    format:"Y-m-d H:i",
    step:10
});

$("#type").change(function(){
    var value = $(this).val();
    if(value == 1){
        $(".pickup").css("display","block");
    }else{
        $(".pickup").css("display","none");
    }
});

$("#candidate").click(function(){
    var iTop = (document.body.clientHeight-30-600)/2; //获得窗口的垂直位置;
    var iLeft = (document.body.clientWidth-10-800)/2; //获得窗口的水平位置;
    window.open('<?=base_url("profile/choice_workers/radio")?>','_blank',
    'width=800,height=600,menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,top='+iTop+',left='+iLeft);
});

function checkform(){
    var flag = true;
//    if($("input[name='noticetime']").val() == ''){
//        $("#timeerr").html("Please select notice time.");
//        flag = false;
//    }else{
//        $("#timeerr").html("*");
//    }
    
    if($.trim($("input[name='title']").val()) == ''){
        $("#titleerr").html("Please input title.");
        flag = false;
    }else{
        $("#titleerr").html("*");
    }
    
    var type = $("#type").val();
    if(type == 1){
        if($.trim($("input[name='fltno']").val()) == ''){
            $("#fltnoerr").html("Please input flight number.");
            flag = false;
        }else{
            $("#fltnoerr").html("*");
        }
        
        if($.trim($("input[name='terminal']").val()) == ''){
            $("#terminalerr").html("Please input the terminal.");
            flag = false;
        }else{
            $("#terminalerr").html("*");
        }
        
        if($("input[name='arrivetime']").val() == ''){
            $("#arrivetimeerr").html("Please select arrive time.");
            flag = false;
        }else{
            $("#arrivetimeerr").html("*");
        }
    }
    
    return flag;
}
window.opener.location.reload();
$(".close").click(function(){
    $(".dialogdiv").css("display","none");
    $(".dialogbgdiv").css("display","none");
});
$(".showinfo").click(function(){
    var noticeid = $(this).attr("noticeid");
    $("#dialogdiv"+noticeid).css("display","block");
    $("#dialogbgdiv"+noticeid).css("display","block");
});
</script>
</body>
</html>